#!/bin/sh

"${CMAKE_COMMAND}" -G"${CMAKE_GENERATOR}" \
    -S "${CMAKE_SOURCE_DIR}" \
    -B "${NATIVE_BUILD_DIR}" \
    -D__IS_NATIVE_BUILD=1 \
    -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} \
    ${ARGS}

# Ok let's generate a depfile if we can.
if test "x${CMAKE_GENERATOR}" = "xNinja"; then
    "${CMAKE_SOURCE_DIR}/cmake/utils/gen-ninja-deps.py" \
        --build-dir "${NATIVE_BUILD_DIR}" \
        --base-dir "${CMAKE_BINARY_DIR}" \
        --ninja "${CMAKE_MAKE_PROGRAM}" \
        native/CMakeCache.txt build.ninja \
        --extra-deps build.ninja \
            > "${NATIVE_BUILD_DIR}/CMakeFiles/CMakeCache.txt.d"
fi
